package org.csu.demopetstore.Persistence;

import org.apache.ibatis.annotations.Param;
import org.csu.demopetstore.entity.Cart;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

@Repository
public interface CartMapper {

    //根据用户名查所有的cart
    List<Cart> getCartList(@Param("username")String username);
    //插入cart
    void insertCart(Cart cart);
    //根据cart中的username和itemid查询cart
    Cart getCartByUsernameAndItemid(@Param("username")String username, @Param("itemid")String itemid);
    //修改cart,查询和修改的值都要传进来
    void updateCart(@Param("username")String username, @Param("itemid") String itemid, @Param("quantity")int quantity, @Param("total") BigDecimal total);
    //查询instock
    boolean getInstock(@Param("itemid")String itemid);

    void deleteCartByUsernameAndItemid(@Param("username")String username, @Param("itemid")String itemid);
    //计算总价钱
    BigDecimal calculation(@Param("username")String username);
    //清空购物车
    void deleteAllCart(@Param("username")String username);


}
